<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<ui:composition>
    <p:layoutUnit position="west">
        <h:form id="menu">
            <p:menu>
                <p:menuitem value="Main page" actionListener="#{navigationBean.action('main.xhtml')}"/>
                <p:menuitem value="All documents" actionListener="#{navigationBean.action('all.xhtml')}"/>
                <p:menuitem value="Upload document" actionListener="#{navigationBean.action('upload.xhtml')}"/>
                <p:menuitem value="File management" actionListener="#{navigationBean.action('management.xhtml')}" rendered="#{userBean.user.role.idRole != 1}"/>
                <p:menuitem value="Terms of use" actionListener="#{navigationBean.action('terms.xhtml')}"/>
                <p:menuitem value="Contacts" actionListener="#{navigationBean.action('contact.xhtml')}"/>
            </p:menu>
        </h:form>

        <h:form id="signIn" rendered="#{userBean.user.role.idRole == 1}">
            <p:outputLabel value="Welcome #{userBean.user.role.name}"/>
            <br/>
            <p:messages id="signInMes" showDetail="true" closable="true" style="width: 220px;"/>
            <p:panel header="Sign in" style="width:220px;height:160px;" >
                <h:panelGrid columns="2">
                    <p:outputLabel for="login" value="Login"/>
                    <p:inputText id="login" value="#{userBean.user.login}" style="width: 70px;" required="true">
                        <f:validateLength minimum="4"/>
                    </p:inputText>
                    <p:outputLabel for="pass" value="Password"/>
                    <p:password id="pass" value="#{userBean.user.password}" style="width: 70px;" required="true">
                        <f:validateLength minimum="5"/>
                    </p:password>
                </h:panelGrid>
                <p:commandButton value="Sign in" actionListener="#{userBean.signIn}" update="signInMes"/>
            </p:panel>
        </h:form>

        <h:form id="reg" rendered="#{userBean.user.role.idRole == 1}">
            <p:outputLabel value="or "/>
            <p:commandLink value="register" actionListener="#{navigationBean.action('register.xhtml')}"/>
        </h:form>

        <h:form id="signOut" rendered="#{userBean.user.role.idRole != 1}">
            <p:outputLabel value="Welcome #{userBean.user.login}"/>
            <br/>
            <p:commandButton value="Sign out" actionListener="#{userBean.signOut}"/>
        </h:form>
    </p:layoutUnit>
</ui:composition>
</html>
